package one.jieyun.ajzw.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.rollviewpager.RollPagerView;
import com.jude.rollviewpager.adapter.LoopPagerAdapter;
import com.squareup.picasso.Picasso;

import java.util.List;
import one.jieyun.ajzw.module.ListViewSubItem;

/**
 * Created by Administrator on 2016/8/31.
 */
public class SliderAdapter  extends LoopPagerAdapter {
    List<ListViewSubItem> list;
    public void setLists(List<ListViewSubItem> list){
        this.list = list;
        notifyDataSetChanged();
    }

    public SliderAdapter(RollPagerView viewPager) {
        super(viewPager);
    }

    @Override
    public View getView(ViewGroup container, int position) {
        final Context context = container.getContext();
        ImageView view = new ImageView(context);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        ListViewSubItem slider= list.get(position);
        Picasso.with(context).load(slider.getImage()).into(view);
        return view;
    }

    @Override
    public int getRealCount() {
        if(list == null){
            return 0;
        }
        return list.size();
    }
}
